{template admin/head}
<script type="text/javascript" src="{STATICDIR}third/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
function submitcheck()
{
	return true;
}

function saveInfo()
{
	if(!submitcheck())
	{
		return;
	}
	var url = '{SITE_URL}ajax/admin.php?m=saveChanpin';
	
	var data = $('#savedata').serialize();
		
	var callback = function(data)
	{
		if(data.sign == -2)
		{
			window.location = data.url;
		}
		else
		{
			if(data.sign == 1)
			{
				{if empty($chanpin[id])}
				layer.msg(data.msg, {
			      icon: 6
			      ,time:0
			      ,btn: ['立即发布','暂缓发布','项目列表']
			      ,btn1:function(){
			      		var url = '{SITE_URL}ajax/admin.php?m=cpStatus';
						var data1 = {
								'id' : data.id,
								'status':'2',
								'str':'发布',
						};
						var callback = function(data2){
							if(data2.sign == 1)
							{
								layer.alert(data2.msg,function(){
									window.location = $('#gotoList').attr('href');
								});
							}
							else
							{
								if(data2.msg)
								{
									layer.msg(data2.msg);
								}
								else
								{
									layer.msg('操作失败');
								}
							}
						};
						makeAjax('post',url,data1,callback);
			      	}
			      ,btn2:function(){
			      		window.location = $('#gotoList').attr('href');
			      	}
			      ,btn3:function(){
			      		window.location = '{SITE_URL}admin.php?a={$action}&m=itemlist&pid='+data.id;
			      	}
			    });
			    {else}
				    layer.alert(data.msg,function(){
						window.location = $('#gotoList').attr('href');
					});
			    {/if}
				
				//添加成功,返回列表页
				/*layer.alert(data.msg,function(){
					window.location = $('#gotoList').attr('href');
				});*/
			}
			else
			{
				if(data.msg)
				{
					layer.msg(data.msg);
				}
				else
				{
					layer.msg('操作失败');
				}
			}
		}
	};
	makeAjax('post',url,data,callback);
}

function sum()
{
	var str = $('#shuoming').val();
	var len = str.length; 
	$('#zishu').text(len);
	if(len>70)
	{
		$('#shuoming').val(str.substr(0,70));
	}
}

</script>
<body>
<div class="wrapper">
	<div class="crumbs"><a href="javascript:;">产品管理</a> &gt;<a id="gotoList" href="{SITE_URL}admin.php?a=chanpinM">产品列表</a> &gt; <span>{$pagetitle}</span> </div>
	
	<div class="container_tit clearfix mb20 ft14">
	
	<form id="savedata">
		<input type="hidden" name="id" value="{$chanpin[id]}" />
		<h2 class="form_tit">产品基本信息</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">产品名称：</label>
				<input placeholder="20个字以内" type="text" id="name" name="name" value="{$chanpin[name]}" class="text w340" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">产品标题：</label>
				<input placeholder="20个字以内" type="text" id="title" name="title" value="{$chanpin[title]}" class="text w340" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">产品LOGO上传：</label>
				<a id="btn1" href="javascript:;" class="btnyellow mr15">上传图片</a>
				<img id="img_logo" src="{UPLOAD_IMG_URL}{$chanpin[logo]}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="logo" name="logo" value="{$chanpin[logo]}" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">关键词：</label>
				<input type="text" name="keyw1" value="{$chanpin[keyw1]}" class="text w130" />
				<input type="text" name="keyw2" value="{$chanpin[keyw2]}" class="text w130" />
				<input type="text" name="keyw3" value="{$chanpin[keyw3]}" class="text w130" />
			</p>
		</div>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">更多文字说明：</label>
				<textarea id="shuoming" name="shuoming" onkeyup="sum();" maxlength="70" class="w340" rows="5">{$chanpin[shuoming]}</textarea>
				<span>当前字数</span><span style="color:red" id="zishu">0</span><span>/70字</span>
				<script>sum()</script>
			</p>
		</div>
		<h2 class="form_tit">产品详细信息</h2>
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">产品banner图上传：</label>
				<a id="btn2" href="javascript:;" class="btnyellow mr15">上传图片</a>
				<img id="img_conc" src="{UPLOAD_IMG_URL}{$chanpin[conc]}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="conc" name="conc" value="{$chanpin[conc]}" />
			</p>
		</div>
		
		<div class="form_item clearfix">
		    <p class="clearfix">
				<label class="name">操作说明图片上传：</label>
				<a id="btn3" href="javascript:;" class="btnyellow mr15">上传图片</a>
				<img id="img_caozuo" src="{UPLOAD_IMG_URL}{$chanpin[caozuo]}"  style="max-width: 65px;height: 40px;" />
				<input type="hidden" id="caozuo" name="caozuo" value="{$chanpin[caozuo]}" />
			</p>
		</div>
		
        <div class="form_item clearfix" style="padding-top: 20px;>
			<p class="clearfix">
			    <input type="button" class="btnblue" value="提交" onclick="saveInfo();" />
			</p>
			<span id="tip_type"></span>
		</div>
    </form>
    </div>
</div>
<script>
    var uploader = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn1', // 上传按钮
        url: "{SITE_URL}ajax/uploadImgs.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '2mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{UPLOAD_IMG_URL}';
	                $("#img_logo").attr('src',picurl+data.name);
	                $("#logo").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader.init();
    
     var uploader2 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn2', // 上传按钮
        url: "{SITE_URL}ajax/uploadImgs.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '2mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader2.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader2.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{UPLOAD_IMG_URL}';
	                $("#img_conc").attr('src',picurl+data.name);
	                $("#conc").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader2.init();
    
    
     var uploader3 = new plupload.Uploader({//创建实例的构造方法
        runtimes: 'html5,flash,silverlight,html4', //上传插件初始化选用那种方式的优先级顺序
        browse_button: 'btn3', // 上传按钮
        url: "{SITE_URL}ajax/uploadImgs.php", //远程上传地址
        flash_swf_url: '{STATICDIR}plupload/Moxie.swf', //flash文件地址
        silverlight_xap_url: '{STATICDIR}plupload/Moxie.xap', //silverlight文件地址
        filters: {
            max_file_size: '2mb', //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
            mime_types: [//允许文件上传类型
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: false, //true:ctrl多文件上传, false 单文件上传
        init: {
            FilesAdded: function(up, files) { //文件上传前
                if ($("#ul_pics").children("li").length > 30) {
                    ts("您上传的图片太多了！");
                    uploader3.destroy();
                } else {
                    var li = '';
                    plupload.each(files, function(file) { //遍历文件
                        li += "<li id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></li>";
                    });
                    $("#ul_pics").append(li);
                    uploader3.start();
                }
            },
            UploadProgress: function(up, file) { //上传中，显示进度条
         var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function(up, file, info) { //文件上传成功的时候触发
	               var data = eval("(" + info.response + ")");
	               
	                var picurl = '{UPLOAD_IMG_URL}';
	                $("#img_caozuo").attr('src',picurl+data.name);
	                $("#caozuo").val(data.name);
	              //  _upload_callback(data.name,data.size);
	            },
            Error: function(up, err) { //上传出错的时候触发
                layer.msg(err.message);
            },
            UploadComplete:function()
            {
            	layer.msg('上传成功');

            	//window.location = window.location;
            }
        }
    });
    uploader3.init();
</script>
</body>
</html>